﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class WeatherController : MonoBehaviour
{

    [SerializeField] private Material sky;
    [SerializeField] private Light sun;

    private float _fullIntensity;

    private float _cloudValue = 0f;

    

	// Use this for initialization
	void Start ()
	{
        //初始灯光最开始为满强度
	    _fullIntensity = sun.intensity;
	}
	
	// Update is called once per frame
	void Update ()
	{
        //持续过度每帧的增加值
	    SetOvercast(_cloudValue);
	    _cloudValue += 0.005f;
	}

    //同时调整材质的Blend值和灯光强度值
    void SetOvercast(float value)
    {
        sky.SetFloat("_Blend",value);
        sun.intensity = _fullIntensity - (_fullIntensity * value);
    }

    
}
